import {reqOrderInfo, reqUserAddressInfo} from "@/api";

const state={
    userAddressInfo:[],
    orderInfo: {},
}
const actions={
    async getUserAddressInfo(context){
        let result=await reqUserAddressInfo();
        if(result.code==200){
            context.commit('GETUSERADDRESSINFO',result.data)
        }else {
            return Promise.reject(new Error('fail'+result.message))
        }
    },
    async getOrderInfo(context){
        let result=await reqOrderInfo();
        console.log(result)
        if(result.code==200){
            context.commit('GETORDERINFO',result.data)
        }else {
            return Promise.reject(new Error('fail'+result.message))
        }
    }
}
const mutations={
    GETUSERADDRESSINFO(state,value){
        state.userAddressInfo=value||[];
    },
    GETORDERINFO(state,value){
        state.orderInfo=value||{};
    }
}
const getters={}
export default {
    state,
    actions,
    mutations,
    getters,
}